package com.ragdollcat.thirdaicodegenerate.core.saver;


import com.ragdollcat.thirdaicodegenerate.core.HtmlCodeResult;
import com.ragdollcat.thirdaicodegenerate.core.MultiFileCodeResult;
import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * 保存文件代码执行器
 */
@Slf4j
public class CodeFileSaverExecutor {

    private static final HtmlCodeFileSaverTemplate HTML_CODE_FILE_SAVER_TEMPLATE = new HtmlCodeFileSaverTemplate();

    private static final MutliFileSaverTemplate MUTLI_FILE_SAVER_TEMPLATE = new MutliFileSaverTemplate();


    public static File getCodeFile(Object result, String bizType, Long appId,int version) {
        switch (bizType) {
            case "html" -> {
                return HTML_CODE_FILE_SAVER_TEMPLATE.saveCode((HtmlCodeResult) result,appId,version);
            }
            case "multi_file" -> {
                return MUTLI_FILE_SAVER_TEMPLATE.saveCode((MultiFileCodeResult) result,appId,version);
            }
            default -> {
                log.info("该种任务类型：{}不支持！",bizType);
                return null;
            }
        }
    }

}
